<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<!-- v-on 指令，参数传递，特殊传递：事件 $event -->
<body>
    <div id="app">
        <div>            
            
            <h2>不带参数</h2>
            <button @click="btnClick1()">按钮1 -- btnClick1()</button>
            <button @click="btnClick2">按钮2 -- btnClick2</button>

            <h2>带参数</h2>
            <button @click="btnClick3(123, 'abc', true, msg)">按钮3 -- btnClick3(123, 'abc', true, msg)</button>
            <button @click="btnClick4(123, $event)">按钮4 -- btnClick4(123, $event)</button>
        </div>
    </div>
    <script src="js/vue.js"></script>

    <script>
        const HelloVue = {
            data(){
                return {
                    msg: "消息",
                }
            },
            methods: {
                btnClick1(args){  
                    console.log(args);  // undefined
                },
                btnClick2(args){
                    console.log(args);  // 事件对象
                },
                btnClick3(arg1, arg2, arg3, arg4){
                    // 这里的 arg4 是 data 中定义的参数
                    console.log(arg1, arg2, arg3, arg4);  // 打印传入值
                },
                btnClick4(args, args1){
                    console.log(args, args1);     // 使用 dom 元素的事件对象
                },
                
            }
        };

        const app = Vue.createApp(HelloVue).mount("#app");
       
    </script>
</body>
</html>